<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<script language="JavaScript">
		function check(form){
			
			var errorStr="";
			var teaid = stuForm.elements[0].value; //读取form表单中的值
			var teaname = stuForm.elements[1].value;
			var teapassword = stuForm.elements[2].value;
			var teaemail = stuForm.elements[3].value;
			//alert(Number.MAX_VALUE);
			
			var pattern = /^\d{9}$/;
			var email = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
			if(!pattern.test(teaid)){
				errorStr = "账号必须由9数字组成"	;
				alert(errorStr);
				return false;		
			}else if (teaname==""){
				alert("姓名不能为空");
				return false;
			
			}else if(teapassword==""){
				alert("密码不能为空");
				return false;
			}else if(!email.test(teaemail)){
				alert("请输入正确的邮箱格式");
				return false;
			}
			}
	</script>
  </head>
  
  <body>
    <form id="stuForm" action="register" method="post" onSubmit="return check(this)">
    	<center>
    	<table border="1" style="margin-top: 50px;">
    		<tr>
    			<th colspan="3" style="font-size: 24">教师注册</th>
    		</tr>
    		<tr>
    			<td>教师号：</td>
    			<td><input type="text" name="tea.teaUserID" maxlength="9"/></td>
    			<td>请输入9位有效数字</td>
    		</tr>
    		<tr>
    			<td>姓名：</td>
    			<td><input type="text" name="tea.teaName" maxlength="8"/></td>
    			<td>请输入姓名</td>
    		</tr>
    		<tr>
    			<td>密码：</td>
    			<td><input type="password"  name="tea.teaPassword" maxlength="10"/></td>
    			<td>请输入密码</td>
    		</tr>
    		<tr>
    			<td>Email：</td>
    			<td><input type="text" name="tea.teaEmail" maxlength="20"/></td>
    			<td>请正确填写邮箱格式</td>
    		</tr>
    		<tr>
    			<td colspan="3" >
    				<input type="submit" id="sumbit"  value="提交" style="margin-left: 80px;"/>
    				<input type="reset" value="重置" style="margin-left:115px;"/>
    			</td>
    		</tr>
    	</table>
    </center>
    </form>
  </body>
</html>
